package com.wh.semaphore;

import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.ReentrantLock;

public class TestObj {
	
	private ReentrantLock lock = new ReentrantLock();
	private Condition condition = lock.newCondition();

	public void relock() {
		try {
			lock.lock(); 
		} catch(Exception e) {
			lock.unlock();
		}
	}
	
	public synchronized void add() {
		try {
			System.out.println("进入等待");
			this.wait(10000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}
	
	public void add1() {
		for(;;) {
			System.out.println("==========");
		}
	}
	
	public void add2() {
		try {
			Thread.currentThread().sleep(2000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}
}
